package jellis.android.hellotabwidget;


import android.app.ListActivity;
import android.content.Intent;
import android.database.Cursor;
import android.os.Bundle;
import android.view.Menu;
import android.view.View;
import android.widget.ArrayAdapter;
import android.widget.ListView;
import android.widget.SimpleCursorAdapter;

public class Viewer extends ListActivity{
	private PlannerDbAdapter mDbHelper;
	String invoer1 = "oefen";
	String invoer2 = "test";
	
	public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        mDbHelper = new PlannerDbAdapter(this);
        mDbHelper.open();
        fillData();
    }
	
	public void fillData(){
		Cursor lijst = mDbHelper.fetchAllAfspraken();
		startManagingCursor(lijst);
		
		final String[] afspraken = new String[] {PlannerDbAdapter.KEY_DATUM, PlannerDbAdapter.KEY_AFSPRAAK};
		
        // and an array of the fields we want to bind those fields to
        int[] to = new int[]{R.id.text1, R.id.text2};

        // Now create a simple cursor adapter and set it to display
        SimpleCursorAdapter notes = 
            new SimpleCursorAdapter(this, R.layout.afspraakrow, lijst, afspraken, to);
        setListAdapter(notes);
	}
	
	@Override
    protected void onListItemClick(ListView l, View v, int position, long id) {
        fillData();
    }
}